<?php


/**
 * Class for Password Validation
 *
 * @category   Zend
 * @uses       Zend_Validate_Abstract
 * @subpackage Zend_Validate
 * @copyright  Copyright (c) 2009 East Hui Van Business Consulting Co., Ltd. (http://www.easthv.com)
 */
class Zend_Validate_Password extends Zend_Validate_Abstract
{
    /**
     * Validation failure message key
     */
	const NOT_MATCH = 'notMatch';
	const INPUT_INCORRECT = 'inputIncorrect';


    /**
     * Validation failure message template definitions
     *
     * @var array
     */
    protected $_messageTemplates = array(
        self::NOT_MATCH    => "password not match",
        self::INPUT_INCORRECT    => "input password must be array"
	);

    /** 
     * Defined by Zend_Validate_Interface 
     * 
     * Returns true if and only if the input password is same as confirm password
     * 
	 * @param string $value
	 *
     * @return boolean 
     */ 
    public function isValid($value)
	{

		if (!is_array($value) || count($value) < 2) {
            $this->_error(self::INPUT_INCORRECT);
            return false;
		}

        $this->_setValue($value);

        if ($value[0] !== $value[1]) {
            $this->_error(self::NOT_MATCH);
            return false;
        }

        return true;
    }

}
